package com.ctg.behavior.calc.impala.builder.userlist;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.ctg.behavior.common.retentions.CtRetentionsSliceBody;
import com.ctg.behavior.common.userslist.CtULCalcBody;

@Component
public class CtRetentionsExtCalcBodyBuilder {

	public CtRetentionsSliceBody doBuilder(CtULCalcBody ulCalcBody) {

		CtRetentionsSliceBody retentionsExtCalcBody = null;
		retentionsExtCalcBody = JSON.parseObject(ulCalcBody.getUpperTaskData(), CtRetentionsSliceBody.class);

		// 把CtUpperFunnelBody转为CtFunnelExtCalcBody
		retentionsExtCalcBody.setAppId(ulCalcBody.getAppId());
		retentionsExtCalcBody.setRequestId(ulCalcBody.getRequestId());
		retentionsExtCalcBody.setBookmarkId(ulCalcBody.getBookmarkId());

		retentionsExtCalcBody.setSubTaskType(ulCalcBody.getUpperTaskType());

		// TEMP
		if (!retentionsExtCalcBody.getUserFilter().getConditions().isEmpty()) {
			retentionsExtCalcBody.setFilter(retentionsExtCalcBody.getUserFilter());
		}

		return retentionsExtCalcBody;

	}

}
